﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Joyintech.Model.inpiao365;
using Joyintech.BLL.inpiao365;

namespace Joyintech.Web.inpiao365.PhenixTicket
{
    public partial class addOrder : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
            if (!this.IsPostBack)
            {
                int orderid = AddMovie();
                if (orderid > 0)
                {
                    Response.Redirect("phenix_PayCenter.aspx?id=" + orderid + "&rewurl=" + Request.RawUrl);
                }
            }
        }

        /// <summary>
        /// 增加订单
        /// </summary>
        /// <returns></returns>
        protected int AddMovie()
        {
            customer currentCustomer = customer_BLL.GetInstance().GetCurrentCustomer();

            if (currentCustomer != null)
            {
                int MovieId = int.Parse(Request.QueryString["lsh"]); //电影编号
                int TheaterId = int.Parse(Request.QueryString["yyh"]); //影院编号
                int TheaterRoomId = int.Parse(Request.QueryString["yth"]); //影厅编号
                int ScreeningsId = int.Parse(Request.QueryString["cc"]); //场次
                string MovieSeatId = Request.QueryString["row"]; //座位号
                string RecMobile = Request.QueryString["mobile"];//手机号码

                order model = new order();
                model.MovieId = MovieId;
                model.TheaterId = TheaterId;
                model.TheaterRoomId = TheaterRoomId;
                model.ScreeningsId = ScreeningsId;
                model.MovieSeatId = MovieSeatId;
                model.CustomerId = currentCustomer.CustomerId;
                model.OrderTime = DateTime.Now;
                model.RecMobile = RecMobile;

                order_BLL bll = new order_BLL();
                return bll.Add(model);
            }
            else
            {
                return 0;
            }

        }
    }
}